<template>
    <div>
        <div class="btns">
            <el-button type="primary" size="small" @click="toFormHandler">新增</el-button>     
        </div>
        <div class="tab_content">
            <el-table :data="callLogs" style="width: 100%">
                <el-table-column prop="id" label="序号" width="180"></el-table-column>
                <el-table-column prop="callTime" label="识别时间" width="180">
                     <template slot-scope="scope">
                    {{scope.row.callTime| fmtTime}}
                    </template>  
                </el-table-column>
                <el-table-column prop="comment" label="识别结果" align="center"  >
                    <template slot-scope="scope">
                        <el-button type="text" @click="lookcomment(scope.row)">查看</el-button>
                    </template>
                    
                </el-table-column>
                <!-- 操作列 -->
                <el-table-column width="100" align="center" label="操作">
                <template slot-scope="scope">
                    <el-button type="text" @click="editHandler(scope.row)">修改</el-button>
                    <el-button type="text" @click="deleteHandler(scope.row)">删除</el-button>
                </template>
                </el-table-column>
             </el-table>
        </div>
    </div>
</template>

<script>
import { del, get } from '@/utils/request'
export default {
    data(){
        return{
            callLogs:[]
        }
    },
    
    methods:{
        lookcomment(row){
            

            this.$router.push({
                path:"/message/tth_recognition_form",
                query:row
            })
        },
        editHandler(row){
            this.$router.push({
                    path:"/message/call_form",
                    query: row
                }
            )
        },
        deleteHandler(row){
            this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                let url = "http://localhost:8888/callLog/deleteById"
                del(url,{id:row.id}).then(resp => {
                    // 1. 提示
                    this.$message({type:"success",message:resp.message});
                    // 2. 刷新
                    this.loadCallLogs()
                })
            })
        },
        toFormHandler(){
            this.$router.push({
                path:"/message/call_form"
            })
        },
        loadCallLogs(){
            let url = "http://localhost:8888/callLog/query"
            get(url).then(resp => {
                // 获取数据之后做的事情
                //控制台打印数据
                console.log(resp.data)
                //将从接口获取到的data存放到messages中
                this.callLogs=resp.data
            })
        }


    },


    created(){
        this.loadCallLogs()
    }
}
</script>

<style lang="sass" scoped>

</style>>
 